<template>
	<view class="content">
		<view class="set-hd">
			<view class="set-img" :style="'background: url('+(user.avatar ? user.avatar : '/static/default.png')+') center center /100% auto no-repeat;'"></view>
			<view class="set-phone">
				{{user.mobile}} <!--<text>修改</text>-->
			</view>
		</view>
		
		<view class="place-time">
			<view class="place-time-tp">
				<view class="place-time-name">昵称</view>
				<view class="place-time-con">
					<text>{{user.nickname}}</text>
				</view>
			</view>
			<view class="place-time-tp" @tap="goApply()">
				<view class="place-time-name">个人信息</view>
				<view class="place-time-con">
					<text>{{Object.keys(techn).length > 0 ? '已认证' : '去申请'}}</text>
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="place-time-tp">
				<view class="place-time-name">注册日期</view>
				<view class="place-time-con">
					<text>{{user.add_time_time}}</text>
				</view>
			</view>
		</view>
		
		<view class="place-time">
			<view class="place-time-tp" @tap="goWeb('ysxy')">
				<view class="place-time-name">用户隐私协议</view>
				<view class="place-time-con">
					<text></text>
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
			<view class="place-time-tp" @tap="goWeb('yhxy')">
				<view class="place-time-name">个人信息保护指引</view>
				<view class="place-time-con">
					<text></text>
					<text class="iconfont icon-jinrujiantou"></text>
				</view>
			</view>
		</view>
		
		<view class="h110"></view>
		
		<view class="detail-sel">
			<navigator class="detail-btn" @click="logout">退出登录</navigator>
		</view>	
	</view>
</template>

<script>
const app = getApp();
const request = require('../../utils/request');
export default {
    data() {
        return {
			//用户信息
			user:{},
			techn:{}, //技师信息
        }
    },
	onLoad()
	{
		
	},
	onShow()
	{
		var that = this;
		that.load_user_info(); //获取用户信息
	},
    methods: {
		// web
		goWeb(fun){
	        uni.navigateTo({
	            url: '/pages/my/web?fun='+fun
	        })
	    },
		// web
		goApply(){
			//判断是否已成为技师
			var that = this;
			if(Object.keys(that.techn).length > 0)
			{
				//技师修改资料
				uni.navigateTo({
		            url: '/pages/my/edit_techn'
		        });
			}else
			{
				//技师申请
				uni.navigateTo({
		            url: '/pages/my/apply'
		        });
			}
	    },
	    /**
		 * 获取用户信息
		 */
		load_user_info:function()
		{
			var that = this;
			//网络请求
			request(app.globalData.api_url+'/v1/user/index', 'POST', {}).then((res) => {
				if(res.data.code == 0)
				{
					that.user = res.data.data.user;
					that.techn = res.data.data.techn;
				}else
				{
					uni.showToast({
						title:res.data.msg,
						icon:'none'
					});
					app.is_login_check(res.data);
					app.is_techn_check(res.data);
				}
			});
		},
		/**
		 * 退出登录
		 */
		logout:function()
		{
			var that = this;
			uni.clearStorageSync();
			app.is_login_check({code:-400});
		}
    }
}
</script>
<style lang="scss">
page{
	background-color: $uni-bg-color-grey;
}
.content{
	.detail-sel{
		padding: 30rpx 20rpx;
		position:fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: #fff;
		text-align: center;
		.detail-btn{
			height:80rpx;
			line-height: 80rpx;
			border-radius: 35rpx;
			color: #fff;
			font-size: 28rpx;
			background-color:$uni-text-color-active;
		}
	}
	.h110{
		width: 100%;
		height:110rpx;
	}
	.set-hd{
		.set-phone{
			font-size:28rpx;
			color: $uni-text-color-grey;
			text{
				margin-left: 20rpx;
				color:$uni-text-color-active;
			}
		}
		.set-img{
			border-radius: 50%;
			width:150rpx;
			height:150rpx;
			margin:80rpx auto 20rpx;
			background: url(/static/default.png) center center /100% auto no-repeat;
		}
		text-align: center;
		padding:10rpx 30rpx;
		background-color: #fff;
	}
	.place-time{
		margin:0 0 30rpx;
		padding:10rpx 20rpx;
		background-color: #fff;
		.place-time-tp{
			display: flex;
			padding:20rpx 10rpx;
			.place-time-name{
				flex:2;
				font-size:28rpx;
			}
			.place-time-con{
				flex: 1;
				text-align: right;
				vertical-align: middle;
				text{
					&:first-child{
						font-size:28rpx;
						color: $uni-text-color-grey;
					}
					&.iconfont{
						font-size:32rpx;
					}
				}
			}
		}
		.my-order{
			display: flex;
			.my-ord-li{
				flex: 1;
				text-align: center;
				margin-top:15rpx;
				.my-ord-icon{
					margin:10rpx 0;
					text{
						color: $uni-text-color-active;
						font-size:50rpx;
					}
				}
				.my-ord-tit{
					font-size:28rpx;
				}
			}
		}
		.my-app{
			.my-app-li{
				width: 25%;
				display: inline-block;
				text-align: center;
				margin-top:15rpx;
				.my-app-icon{
					margin:10rpx 0;
					text{
						color: $uni-text-color-active;
						font-size:50rpx;
					}
				}
				.my-app-tit{
					font-size:28rpx;
				}
			}
		}
	}
}
</style>